package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anotion.AutoFill;
import com.sky.anotion.AutoId;
import com.sky.dto.common.ParamsID;
import com.sky.dto.common.QueryParams;
import com.sky.entity.Instructor;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper

public interface InstructorMapeer {
    @Select("select * from instructor where employee_number= #{employeeNumber}")
    Instructor getInfoByEID(String employeeNumber);

    /**
     * 根据用户id查询用户信息
     * @param userId 用户id
     * @return
     */
    @Select("select * from instructor where id = #{userId}")
    Instructor getInfoById(String userId);

    /**
     * 根据姓名模糊查询用户信息
     * @param name
     * @return
     */
    List<Instructor> findByName(String name);
    /**根据用户手机号查询*/
    @Select("select * from instructor where phone = #{phone} and status = 1")
    Instructor getInfoByPhone(String phone);

    /**
     * 分页查找获取用户信息
     * @param params
     * @return
     */
    List<Instructor> getAllInstructor(QueryParams params);

    /**
     * 增加用户
     * @param instructor
     */
    @AutoId
    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into instructor (id,name, gender, employee_number, permission_level, password,department_id, create_time, " +
            "update_time, create_user, update_user,avatar,roles,permissions)  values  (#{id},#{name}, #{gender},#{employeeNumber},#{permissionLevel}," +
            "#{password},#{departmentId},#{createTime},#{updateTime},#{createUser},#{updateUser},#{avatar},#{roles},#{permissions})")
    void addInstructor(Instructor instructor);

    @AutoFill(value = OperationType.UPDATE)
    void updateInstructor(Instructor instructorInfoVO);

    /**
     * 删除用户
     * @param id
     * @return
     */
    @Delete("delete from instructor where id = #{id}")
    void deleteInstructorById(String id);

    /**
     * 获取一级部门的负责人id
     * @param ids
     * @return
     */
    List<Instructor> getOnePeople(ParamsID ids);
    /**
     * 获取学校管理员的信息
     */
    @Select("select * from instructor where permission_level = 0")
    List<Instructor> getSchoolManager();

    /**
     * 获取团队负责人的信息
     * @param paramsID
     * @return
     */
    List<Instructor> getTeamManage(ParamsID paramsID);
}
